﻿<!doctype html>
<html lang="">

<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

    <title>@ViewBag.Title</title>

    <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    @Scripts.Render("~/bundles/jquery")

    @*@Scripts.Render("~/bundles/modernizr")*@

</head>
<body>
    @*@if (Session["TenDangNhap"] == null)
    {
        Response.Redirect("~/Home/Login");
    }*@
    <div class="app">
        @* Thanh menu top *@
        @Html.Partial("_Navbar")
        <section class="layout">

            @* Menu ben trai *@
            @Html.Partial("_SideBar")

            <section class="main-content">

                <div class="content-wrap">
                    <div class="wrapper p10" id="content-main">
                        @* Phan noi dung chinh *@
                        @RenderBody()
                    </div>
                    <div id="loading-icon">
                        <img src="~/Content/css/img/loading.gif" />
                    </div>
                </div>

                <a class="exit-offscreen"></a>
            </section>

            @*@Html.Partial("_ChatPanel")*@
        </section>
    </div>
    <div id="notification"></div>


    @Scripts.Render("~/bundles/script")

    @Styles.Render("~/Content/css/admin")

    @Scripts.Render("~/bundles/jqueryval")
    
    @RenderSection("scripts", required: false)
    
    <script>

 
    var tableToExcel = (function () {
        var uri = 'data:application/vnd.ms-excel;base64,'
          , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/><style>table, td, th { border: 1px solid black; border-width: thin}</style></head><body><table style="font-family:\'Times New Roman\';font-size:16px;text-align:left !important;">{table}</table></body></html>'
          , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
          , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
        return function (table, name) {
            if (!table.nodeType) table = $(table).html();
            var ctx = { worksheet: name || 'Worksheet', table: table }
            window.location.href = uri + base64(format(template, ctx))             
        }
    })()
 
 
        
        function cbChonTat(objRef)
        {
            var GridView = objRef.parentNode.parentNode.parentNode.parentNode.parentNode;
            var inputList = GridView.getElementsByTagName("input");
            for (var i = 0; i < inputList.length; i++)
            {
                var row = inputList[i].parentNode.parentNode;
                if (inputList[i].type == "checkbox" && objRef != inputList[i])
                {
                    if (objRef.checked)
                    {
                        inputList[i].checked = true;
                    }
                    else
                    {
                        inputList[i].checked = false;
                    }
                }
            }
        }

        //$('#delete-all').click(function ()
        //{
        //    var grid = $("#griddata").data("kendoGrid");
        //    $('#griddata').kendoGrid({ editable: { confirmation: false } })
        //    $("#griddata").find("tbody input:checked").each(function ()
        //    {
        //        grid.removeRow($(this).closest('tr'));
        //    })
        //    $("#griddata").find("thead input:checked").removeAttr('checked')
        //    $('#griddata').kendoGrid({ editable: { confirmation: true } })
        //})

        $("#loading-icon").hide();
        function AjaxBegin()
        {
            $('#loading-icon').show();

        }
        function AjaxComplete()
        {
            $("#loading-icon").hide();
        }
        function AjaxFailure(ajaxContext)
        {
            var response = ajaxContext.responseText;
            alert("Error: [" + ajaxContext.ErrorCode + "] " + response);
        }


        function onEdit(e)
        {
            //if (e.model.isNew())
            //{
            //    $('.k-window-title').text("Thêm mới");
            //    //e.container.find("label:first").hide();
            //}
            //else
            //{
            //    $('.k-window-title').text("Sửa dữ liệu");
            //}
        }

        function onRequestEnd(e)
        {
            var grid = $("#griddata").data("kendoGrid");
            var data = grid.dataSource;
            if (e.type == "create" || e.type == "update" || e.type == "destroy")
            {
                var notification = $("#notification").kendoNotification().data("kendoNotification");
                //console.log(e.Errors)
                if (!e.response.Errors)
                {
                    if (e.type == "create")
                        data.read();
                    notification.show("Thực hiện thao tác thành công.", "info");
                }
            }
        }
        function onError(e, status) {

            // Cancel changes on any grids on the page that are using this data source
            $('.k-grid').each(function (item) {
                var grid = $(this).data("kendoGrid");
                if (e.sender === grid.dataSource) {
                    grid.cancelChanges();
                }
            });

            if (e.status == "customerror") {
                alert(e.errors);
            }
            else {
                alert("Generic server error.");
            }

        }
        //function onError(e, status) {
        //    if (e.status == "customerror") {
        //        alert(e.errors);
        //        console.log(e.errors)
        //    }
        //    else {
        //        alert("Generic server error.");
        //    }
        //    data.read();
        //}
        //function onError(e, status)
        //{
        //    //var grid = $("#griddata").data("kendoGrid");
        //    //var data = grid.dataSource;
        //    if (e.errors)
        //    {
        //        console.log(e.errors)
        //        var message = "The following errors have occurred:\n";

        //        $.each(e.errors, function (key, value)
        //        {
        //            console.log(e.errors)
        //            console.log(value.errors)
        //            if (value.errors)
        //            {
        //                message += value.errors.join("\n");
        //            }
        //        });
        //        alert(message);
        //        //data.read();
        //    }
        //}
        $('#main-navigation a[data-ajax=true]').click(function ()
        {
            var pageurl = $(this).attr('href');

            if (pageurl != window.location)
            {
                document.title = $(this).html();
                window.history.pushState({ path: pageurl }, $(this).html(), pageurl);
            }
        });

        window.onpopstate = function ()
        {
            $('#content-main').load(location.href)
        };

        $(document).ready(function () {
            $('.button-next').click(function () {

                if ($('#step-1').data('id') == $('#ddlTraningSystem').val())
                    return;
                else
                    $('#step-1').data('id', $('#ddlTraningSystem').val())

                var changeID = $(this).val
                if ($('#ddlTraningSystem').val() == 0) {
                    $.ajax({
                        url: '/CandidateManagement/Step2_Examination',
                        dataType: 'html',
                        success: function (data) {
                            //alert('0')
                            $('#step-1').html('');
                            $('#step-1').html(data);
                        }
                    });
                }
                else if ($('#ddlTraningSystem').val() == 1) {
                    $.ajax({
                        url: '/CandidateManagement/Step2_RecruitingBasic',
                        dataType: 'html',
                        success: function (data) {
                            //alert('1')
                            $('#step-1').html('');
                            $('#step-1').html(data);
                        }
                    });
                }
                else {
                    $.ajax({
                        url: '/CandidateManagement/Step2_Recruiting',
                        dataType: 'html',
                        success: function (data) {
                            //alert('2')
                            $('#step-1').html('');
                            $('#step-1').html(data);
                            $()
                        }
                    });
                }
            });
        });
    </script>
</body>

</html>
